﻿#pragma once
#include "../assimp/include/assimp/scene.h"
#include "PostProcess.h"

namespace DXBase
{
	namespace Loader
	{
		[Windows::Foundation::Metadata::WebHostHidden]
		public ref class Model3D sealed
		{
		private:
			static PostProcessStep defaultPPSteps;


			Platform::String^ filename;
			Assimp::Importer importer;
			const ::aiScene* scene;

			Model3D();
			void PrepareModel();
			int CreateSceneData();

		public:
			property Platform::String^ Filename { Platform::String^ get() { return filename; } };



			// ============ (static) loading
			static PostProcessStep GetDefaultPPSteps();
			static property PostProcessStep DefaultPostProcessSteps
			{ 
				PostProcessStep get() { return defaultPPSteps; }
				void set(PostProcessStep value) { defaultPPSteps = value; }
			}
			static property Platform::String^ LastLoadError;

			[Windows::Foundation::Metadata::DefaultOverload]
			static Windows::Foundation::IAsyncOperation<Model3D^>^ LoadFile(Platform::String^ file) { return LoadFile(file, DefaultPostProcessSteps); }
			static Windows::Foundation::IAsyncOperation<Model3D^>^ LoadFile(Windows::Storage::StorageFile^ file) { return LoadFile(file, DefaultPostProcessSteps); }
			static Windows::Foundation::IAsyncOperation<Model3D^>^ PickFile() { return PickFile(DefaultPostProcessSteps); }

			[Windows::Foundation::Metadata::DefaultOverload]
			static Windows::Foundation::IAsyncOperation<Model3D^>^ LoadFile(Platform::String^ file, PostProcessStep ppSteps);
			static Windows::Foundation::IAsyncOperation<Model3D^>^ LoadFile(Windows::Storage::StorageFile^ file, PostProcessStep ppSteps);
			static Windows::Foundation::IAsyncOperation<Model3D^>^ PickFile(PostProcessStep ppSteps);
		};
	}
}